define([
  'jquery', 
  'underscore', 
  'backbone',
  'views/tweetview',
  'services/tweetservice'
], function($, _, Backbone, TweetView, TweetService){

var TweetRouter = Backbone.Router.extend({
	routes:{
		'': 'home',
		"viewdetail/:id": 'view',
	},
	view: function(id){
		console.log(id);
		var jid = "#"+id;
		$("#detail").remove();
		var tweettmp = TweetService.getTweetById(id);
		var divtemp = "<p id='detail'>Create at: "+tweettmp.get("datecreate")+""+
		"<br/>Retweets: "+tweettmp.get("retweets")+"</p>";
		$(jid).append(divtemp);
	},
	home: function(){
		console.log("At home");
		var tweetview = new TweetView();
	}
});


  var initialize = function(){
    // Pass in our Router module and call it's initialize function
	console.log("create router");
    var tweet_router = new TweetRouter;
	Backbone.history.start();
  };

  return { 
    initialize: initialize
  };
});
